<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>RAM retention example</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51 General Code Examples
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__ram__retention__example.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">RAM retention example</div>  </div>
<div class="ingroups"><a class="el" href="group__nrf__examples__nrf6310.html">nRF6310 example projects</a></div></div>
<div class="contents">

<p>Example usage and verification of RAM retention mode-.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gab2d174d89891ae8797f68acc52dce9da"></a><!-- doxytag: member="ram_retention_example::RAM_MEMORY_TEST_ADDRESS" ref="gab2d174d89891ae8797f68acc52dce9da" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#gab2d174d89891ae8797f68acc52dce9da">RAM_MEMORY_TEST_ADDRESS</a>&#160;&#160;&#160;(0x20002000UL)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Address in RAM where test word (RAM_MEMORY_TEST_WORD) is written before system off and checked after system reset. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaf8685571f82474ca3aea205c93e473f8"></a><!-- doxytag: member="ram_retention_example::RAM_MEMORY_TEST_WORD" ref="gaf8685571f82474ca3aea205c93e473f8" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#gaf8685571f82474ca3aea205c93e473f8">RAM_MEMORY_TEST_WORD</a>&#160;&#160;&#160;(0xFEEDBEEFUL)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Test word that is written to RAM address RAM_MEMORY_TEST_ADDRESS. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga1cbcc1d0486e15cf95ac9a5ba38a842b"></a><!-- doxytag: member="ram_retention_example::RESET_MEMORY_TEST_BYTE" ref="ga1cbcc1d0486e15cf95ac9a5ba38a842b" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#ga1cbcc1d0486e15cf95ac9a5ba38a842b">RESET_MEMORY_TEST_BYTE</a>&#160;&#160;&#160;(0x0DUL)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">known sequence written to special register to check if this wake up from system off. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga4abe38ee95ef2f09955110c9ce7d4f60"></a><!-- doxytag: member="ram_retention_example::MAX_TEST_ITERATIONS" ref="ga4abe38ee95ef2f09955110c9ce7d4f60" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#ga4abe38ee95ef2f09955110c9ce7d4f60">MAX_TEST_ITERATIONS</a>&#160;&#160;&#160;(2)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">maximum numer of iterations this example will run <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaaba028eb05f9da9fcfcc717b5aa2a555"></a><!-- doxytag: member="ram_retention_example::SUCCESS_OUTPUT_VALUE" ref="gaaba028eb05f9da9fcfcc717b5aa2a555" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#gaaba028eb05f9da9fcfcc717b5aa2a555">SUCCESS_OUTPUT_VALUE</a>&#160;&#160;&#160;(0xAB)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">If ram retention is tested MAX_TEST_ITERATIONS, this value will be given as output which can be used by tester. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga19f626ae969d6e28722062a4ea2580b6"></a><!-- doxytag: member="ram_retention_example::PIN_GPIO_WAKEUP" ref="ga19f626ae969d6e28722062a4ea2580b6" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#ga19f626ae969d6e28722062a4ea2580b6">PIN_GPIO_WAKEUP</a>&#160;&#160;&#160;(7)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Gpio pin configured to wakeup system from system off on falling edge. Can be connected to a button which is high when not pressed. <br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga2af56a8bf3197b2f06cac4c0b84ffc3e"></a><!-- doxytag: member="ram_retention_example::HardFault_Handler" ref="ga2af56a8bf3197b2f06cac4c0b84ffc3e" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>HardFault_Handler</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gad95401509856e96fc017818483e7fe29"></a><!-- doxytag: member="ram_retention_example::gpio_config" ref="gad95401509856e96fc017818483e7fe29" args="(void)" -->
static void&#160;</td><td class="memItemRight" valign="bottom"><b>gpio_config</b> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga7b158b0f0109fd51d9aecabdaa7bd047"></a><!-- doxytag: member="ram_retention_example::display_failure" ref="ga7b158b0f0109fd51d9aecabdaa7bd047" args="(void)" -->
static void&#160;</td><td class="memItemRight" valign="bottom"><b>display_failure</b> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ram__retention__example.html#ga840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Example usage and verification of RAM retention mode-. </p>
<p>This example configures the system for ram retention and the triggers a system off. After waking up through gpio pin number 7 (active low) this code checks of the RAM state is conserved by checking the value written before going to system off. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>This example run in a loop <a class="el" href="group__ram__retention__example.html#ga4abe38ee95ef2f09955110c9ce7d4f60">MAX_TEST_ITERATIONS</a> number of times and the loop is generated by a System reset which is generated after wakeup from SYSTEM-OFF mode, does not work in evaluation mode of Keil MDK as scatter files only work in full licensed version. Scatter files are needed for telling the ARM linker whether to initialize RAM or not at system reset. This example specially is designed to run without linker scripts because the RAM_MEMORY_TEST_ADDRESS is chosen to be not used by any variable and hence no linker will try to initialize it at start-up.</dd></dl>
<div class="fragment"><pre class="fragment">
 *                             --------------
 *                            |    RESET     |
 *                             --------------
 *                                   |
 *                             ---------------
 *                            |   Configure   |
 *                            |     Gpio      |
 *                             ---------------
 *                                   |
 *                         READ GPREGRET Register
 *                                   |
 *                         ---------------------
 *                 NO  &lt;--|  SYSTEM_OFF_RESET?  |--&gt; YES
 *                 |       ---------------------      |
 *                 |                                  |
 *       -------------------------           ---------------------
 *      |   write to GPREGRET     |         |   Read Loop count/  |
 *      | test word +  loop_count |&lt;-    ---|   MAX reached?      |---&gt;NO
 *       -------------------------   |   |   ---------------------     |
 *                 |                 |   |                 ------------------------               ----------------
 *       ------------------------    |  YES               |  Verify RAM retention? |--&gt;FAILURE--&gt;|  Loop forever  |
 *      |  Enable RAM RETENTION  |   |   |                 ------------------------               ----------------
 *       ------------------------    | STOP                           |                                   ^
 *                 |                 |                             SUCCESS                                |
 *       ------------------------    |          -------------         |                                   |
 *      | WRITE_TEST_BYTE_TO_RAM |    --True---| ++Loop &lt; 6? |&lt;--------                                   |
 *       ------------------------               -------------                                             |
 *                 |                                 |                                                    |
 *        --------------------                     False                                                  |
 *       | trigger System Off |                      |                                                    |
 *        --------------------                        ----------------------------------------------------
 * </pre></div> <div class="image">
<img src="example_board_setup_a.png" alt="example_board_setup_a.png"/>
<div class="caption">
Use board setup A for this example.</div></div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga840291bc02cba5474a4cb46a9b9566fe"></a><!-- doxytag: member="main.c::main" ref="ga840291bc02cba5474a4cb46a9b9566fe" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p><a class="el" href="group__gpio__example.html#ga840291bc02cba5474a4cb46a9b9566fe">main()</a> function </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0. int return type required by ANSI/ISO standard. </dd></dl>

<p>Definition at line <a class="el" href="nrf6310_2ram__retention__example_2main_8c_source.html#l00122">122</a> of file <a class="el" href="nrf6310_2ram__retention__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
